import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:pornhub_app/assets/styles.dart';
import 'package:pornhub_app/components/app_bar/app_bar_view.dart';
import 'package:pornhub_app/components/image_view.dart';
import 'package:pornhub_app/components/text_view.dart';
import 'package:pornhub_app/model/mine/share_record_model.dart';
import 'package:pornhub_app/utils/color.dart';
import 'package:pornhub_app/utils/extension.dart';
import 'package:pornhub_app/views/mine/mine_%20promotion/mine_promotion_page_controller.dart';
import '../../../../components/no_more/no_data.dart';

class MinePromotionPage extends GetView<MinePromotionPageController> {
  const MinePromotionPage({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: COLOR.color_161616,
      appBar: AppBarView(
        titleText: "我的推广",
      ),
      body: EasyRefresh(
        refreshOnStart: true,
        controller: controller.refreshController,
        onRefresh: () {
          controller.onRefresh();
        },
        onLoad: () {
          controller.onLoad();
        },
        child: Column(
          children: [
            Row(
              children: [
                TextView(
                  text: "我的推广人数：",
                  style: kTextStyle(COLOR.white),
                  fontSize: 14.w,
                  fontWeight: FontWeight.w600,
                )
              ],
            ).marginAll(14.w),
            Expanded(
                child: PagedListView<int, ShareRecordModel>(
              padding: EdgeInsets.only(top: 10, left: 14.w, right: 14.w),
              addAutomaticKeepAlives: true,
              pagingController: controller.pagingControllers,
              builderDelegate: PagedChildBuilderDelegate<ShareRecordModel>(
                firstPageProgressIndicatorBuilder: (context) =>
                    const SizedBox.shrink(),
                newPageProgressIndicatorBuilder: (context) =>
                    const SizedBox.shrink(),
                noMoreItemsIndicatorBuilder: (context) =>
                    const SizedBox.shrink(),
                noItemsFoundIndicatorBuilder: (context) => const NoData(),
                itemBuilder: (context, item, index) {
                  return Container(
                    height: 54.w,
                    margin: EdgeInsets.only(bottom: 16.w),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Row(
                          children: [
                            ImageView(
                              src: item.logo ?? "",
                              width: 54.w,
                              height: 54.w,
                              borderRadius: BorderRadius.circular(54.w),
                            ),
                            TextView(
                              text: "${item.createdAt}",
                              style: kTextStyle(COLOR.white,
                                  fontsize: 15.w, weight: FontWeight.w600),
                            ).marginLeft(6.w)
                          ],
                        ),
                        TextView(
                          text: "${item.createdAt}",
                          style: kTextStyle(COLOR.white.withValues(alpha: 0.6),
                              fontsize: 14.w),
                        )
                      ],
                    ),
                  );
                  // return CommunityCell(model: item);
                },
              ),
            ))
          ],
        ),
      ),
    );
  }
}
